package com.feihao.zhou.controller;


import com.feihao.zhou.domain.User.User;
import com.feihao.zhou.exception.BusinessException;
import com.feihao.zhou.exception.SystemException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ProjectExceptionTest {
    @ResponseBody
    @RequestMapping("/ajaxPojoToControllerExe")
    public User test02(@RequestBody User user) {
        if (user.getAge() > 110) {
            throw new BusinessException("年龄大了！");
        } else if (user.getAge() < 0) {
            throw new SystemException("年龄小了！");
        } else if (!user.getName().equals("Jock")) {
            throw new SystemException("练习！！");
        }
        return user;
    }

}
